<template>
    <div class="Fans-page">
        <div class="header">
            <div class="backIcon" @click="back">
                <img src="../assets/images/back_b_icon.png" alt="">
            </div>
            <div class="title">我的关注({{this.list.length}})</div>
            <div class="right"></div>
        </div>
        <div style="height:40px"></div>
        <div class="fansCon" v-if="showCon">
            <van-list
              v-model="loading"
              :finished="finished"
              @load="onLoad"
              :immediate-check="true"
            >
            <div class="item" v-for="item in list" :key="item.id" @click="showauthor(item.id)">
                <div class="left">
                    <div class="img">
                        <img :src="'https://pic.ecook.cn/web/'+ item.imageid+'.jpg!s1'" v-lazy="'https://pic.ecook.cn/web/'+ item.imageid+'.jpg!s1'" alt="" class="authorImg">
                        <img v-if="item.star == 5" src="../assets/images/v5.png" alt="" class="star">
                        <img v-if="item.star == 4" src="../assets/images/v4.png" alt="" class="star">
                        <img v-if="item.star == 3" src="../assets/images/v3.png" alt="" class="star">
                        <img v-if="item.star == 2" src="../assets/images/v2.png" alt="" class="star">
                        <img v-if="item.star == 1" src="../assets/images/v1.png" alt="" class="star">
                    </div>
                    <div class="fanInfo">
                        <div class="fansname">{{item.name}}</div>
                        <div class="profile one-txt-cut" v-if="item.profile!=''">{{item.profile}}</div>
                        <div class="profile one-txt-cut" v-else>这家伙很懒，什么都没有留下</div>
                    </div>
                </div>
                <!-- <div class="fansright">
                    <div class="gz">
                        <img src="../assets/images/加号_o.png" alt="">
                        关注
                    </div>
                </div> -->
            </div>
            </van-list>
        </div>
        <van-loading size="24px" type="spinner" class="loading" v-if="!showCon">正在拼命加载中...</van-loading>
    </div>
</template>

<script>
export default {
    data() {
        return {
            list: [],//数据列表
            loading: false,
            finished: false,
            flag:false,
            fansfollow:null,//关注
            showCon:true,
        };
    },
    methods: {
        onLoad(){
            setTimeout(() => {
                for (let i = 0; i < 10; i++) {
                    if (this.fansfollow[i]) {
                        this.list.push(this.fansfollow[i]);                      
                    }
                }
                // 加载状态结束
                this.loading = false;

                // 数据全部加载完成
                if (this.list.length >= this.fansfollow.length) {
                  this.finished = true;
                }
            }, 1000);
        },
        //关闭界面
        back(){
            this.$emit('back', this.flag);
        },
        showauthor(id){
            this.$router.push({path:'/author',query:{id}})
            this.$emit('showauthor', id);
        }
    },
    created() {
        let fans = JSON.parse(window.localStorage.getItem("follows"))
        if (fans) {
            this.fansfollow = fans
        }
    },
};
</script>

<style lang="less" scoped>
.Fans-page{
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    background-color: #fff;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001;

    .header{
        width: 100%;
        height: 40px;
        border-bottom: 0.5px solid #ccc;
        display: flex;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 99;
        background-color: #fff;
        
        .backIcon{
            width: 100px;
            height: 100%;
            display: flex;
            align-items: center;
            
            &>img{
                width: 13px;
                height: 20px;
                display: block;
                margin-left: 15px;
            }
        }
        .title{
            flex: 1;
            font-weight: bold;
            text-align: center;
        }
        .right{
            width: 100px;
            height: 100%;
        }
    }
    .fansCon{
        padding: 10px 15px;

        .item{
            width: 100%;
            height: 70px;
            display: flex;
            align-items: center;
            justify-content: space-between;

            .left{
                flex: 1;
                height: 100%;
                display: flex;
                align-items: center;

                .img{
                    width: 40px;
                    height: 40px;
                    position: relative;
                    margin-right: 15px;

                    .authorImg{
                        width: 100%;
                        height: 100%;
                        border-radius: 50%;
                    }

                    .star{
                        width: 15px;
                        height: 15px;
                        position: absolute;
                        bottom: 0;
                        right: 0;
                    }
                }
                .fanInfo{
                    width: 210px;
                    .fansname{
                        font-size: 14px;
                        font-weight: bold;
                        letter-spacing: 0.5px;
                        margin:10px 0;
                    }
                    .profile{
                        font-size: 13px;
                        color: #666;
                    }
                }
            }
            .fansright{
                flex: 0 0 80px;
                height: 100%;
                line-height: 80px;
                display: flex;
                align-items: center;
                
                .gz{
                    width: 100%;
                    height: 20px;
                    padding: 3px 10px;
                    background-color: #fbecd9;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    border-radius: 8px;
                    color: #fbb35a;
                    font-weight: bold;
                    font-size: 13px;

                    &>img{
                        width: 20px;
                        height: 20px;
                        display: block;
                        margin-right: 2px;
                    }
                }
            }

        }
    }
    .loading{
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
</style>